<extend name="Common:base" />
<block name="head">
  <style>
    .superaddition{
      height:44px;
      width:400px;
      position: relative;
      top : 12px;
      z-index: 50;
      left:90px;
    }
    .el-tabs__header{
      border-top:2px solid #ea4b4b;
      border-bottom: 1px solid #c51f1f;
    }
    .el-dialog .el-tabs__header{
      border-top:none;
    }
    .el-tabs--border-card .el-tabs__item{
      border-left: none;
    }
    .el-tabs--border-card .el-tabs__item.is-active {
      background-color: #fff;
      border-right-color: #d3dce6;
      background: #544b8f;
      color: #fff;
    }
    .el-tabs--border-card .el-tabs__header {
      background-color: #fff;
      margin: 0;
    }
    .container > .wrapp > .a > .el-row {
      margin-bottom: 6px;
    }
    .el-tabs--border-card .el-tabs__content{
      padding:0 9px 5px 9px;
    }
    .el-card, .el-menu--horizontal .el-submenu>.el-menu, .el-tabs--border-card{
      box-shadow: none;
    }
    .el-tabs--border-card{
      border: none;
    }
    .el-table__body tr.current-row>td{
      background: rgba(157, 195, 232, 0.7);
    }
    .el-dialog__body {
      padding: 20px 20px;
      color: #475669;
      font-size: 14px;
    }
    .on{
      opacity:0.5;
    }
    .el-tabs__item{
      font-family: Microsoft YaHei;
      color:#0d0f10;
      font-size: 14px;
    }
  </style>
</block>
<block name="body">
  

<div id="app" class="container">

<div class="wrapp" id="appx" v-show="show" style="display: none;">
  <div class="a" id="app3">
  <el-row>
    <el-col :span="24">
        <el-form :inline="true"  label-position="left" ref="searchForm" :model="searchForm">

          <el-form-item prop="field" v-show="false">
            <input type="hidden" v-model="searchForm.field">
          </el-form-item>

          <el-form-item prop="name" >
            <el-input v-model="searchForm.name" size="small" placeholder="客户姓名"></el-input>
          </el-form-item>

          <el-form-item prop="phone" >
            <el-input v-model="searchForm.phone" size="small" placeholder="手机号"></el-input>
          </el-form-item>

          <el-form-item prop="qq" >
            <el-input v-model="searchForm.qq" size="small" placeholder="qq号"></el-input>
          </el-form-item>

          <el-form-item prop="weixin" >
            <el-input v-model="searchForm.weixin" size="small" placeholder="微信号"></el-input>
          </el-form-item>

          <el-form-item prop="type" >
            <el-select v-model="searchForm.type" clearable  size="small" placeholder="请选择客户类型" >
                <el-option v-for="(type, key) in customerType" :label="type" :value="key" ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item prop="group" >
            <el-select v-model="searchForm.group" size="small" clearable  placeholder="请选择小组" @change="groupChange">
              <el-option v-for="item in searchGroup" :label="item.name" :value="item.id" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item prop="user_id" >
            <el-select v-model="searchForm.user_id" size="small" clearable  placeholder="请选择队员">
              <el-option v-for="item in memeberList" :label="item.realname" :value="item.user_id" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
          <el-row>
            <el-form-item prop="start" label="锁定起始时间">
            <el-date-picker v-model="searchForm.start" size="small" placeholder="请选择起日期" @change="startDateChange">
            </el-date-picker>
          </el-form-item>

          <el-form-item prop="end" label="锁定截止时间">
                <el-date-picker v-model="searchForm.end" size="small" placeholder="请选择止日期" @change="endDateChange">
                </el-date-picker>
              </el-form-item>

           <el-form-item prop="start" label="最后跟踪起始时间">
                <el-date-picker v-model="searchForm.track_start" size="small" placeholder="请选择起日期" @change="startTrackChange">
                </el-date-picker>
              </el-form-item>

            <el-form-item prop="end" label="最后跟踪截止时间">
                <el-date-picker v-model="searchForm.track_end" size="small" placeholder="请选择止日期" @change="endTrackChange">
                </el-date-picker>
              </el-form-item>
          </el-row>

          

         

         <el-form-item>
           <el-button type="info"  size="small" icon="search" @click="searchFunction">查询</el-button> 
           <el-tooltip content="清空搜索框并刷新表格数据" placement="bottom-start">
             <el-button size="small" @click="searchReset">重置</el-button>
           </el-tooltip>
           <!-- <el-button size="small" @click="toggleShow">{{ buttonText }}</el-button> -->
         </el-form-item>

        </el-form>
    </el-col>
  </el-row>

  <el-row>
    <el-col :span="24">
          <el-tooltip content="跟踪的客户" placement="bottom-start">
            <el-button type="info" size="small" v-bind:class="{on:flag==1}" @click="setField('log',1)">跟踪</el-button>
          </el-tooltip>

          <el-tooltip content="没有跟踪的客户" placement="bottom-start" style="margin-left:10px;">
            <el-button type="info" size="small" v-bind:class="{on:flag==2}" @click="setField('unlog',2)">未跟踪</el-button>
          </el-tooltip>

          <el-tooltip content="计划跟踪的客户" placement="bottom-start" style="margin-left:10px;">
           <el-button type="info" size="small" v-bind:class="{on:flag==3}" @click="setField('plan',3)" >计划</el-button>
          </el-tooltip>

          <!-- <el-tooltip content="把客户转给其它部门的客户" placement="bottom-start">
            <el-button type="info" size="small" @click="setField('transfto')">转让</el-button>
          </el-tooltip>

          <el-tooltip content="他人把客户转给本部门的客户" placement="bottom-start">
            <el-button type="info" size="small" @click="setField('transfin')">转入</el-button>
          </el-tooltip> -->

          <el-tooltip content="成交了的客户" placement="bottom-start" style="margin-left:10px;">
            <el-button type="primary" size="small" v-bind:class="{on:flag==4}" @click="setField('type',4)">服务</el-button>
          </el-tooltip>

          <el-tooltip content="被冲突" placement="bottom-start" style="margin-left:10px;">
            <el-button type="warning"size="small" v-bind:class="{on:flag==5}" @click="setField('conflict',5)">冲突</el-button>
          </el-tooltip>

          <el-tooltip content="客户预查" placement="right" style="margin-left:10px;">
            <el-button  size="small" @click="openDialog('preCheck')" type="primary">{:L('CUSTOMER_PRE_CHECK')}</el-button>
          </el-tooltip>

          <el-tooltip content="离职员工客户资料" style="margin-left:10px;">
            <el-button  size="small"  type="primary" @click="openDialog('quitOut')" >离职客户资料</el-button>
          </el-tooltip>

          <el-tooltip content="点击刷新当前页面" placement="right" style="margin-left:10px;">
            <el-button size="small" @click="refresh" type="danger">刷新</el-button>
          </el-tooltip>


    </el-col>

  </el-row>

  <el-row>
    <el-col :span="24">
        <el-table 
      :data="dataList" 
      border  
      v-loading="dataLoad" 
      element-loading-text="{:L('DATA_LOGIN')}"
      highlight-current-row
      @selection-change="handleSelectionChange"
      @row-click="trackLog"  ref="select" 
      @row-dblclick="userInfo" @sort-change="sortChange">

        <el-table-column type="selection"  width="50" ></el-table-column>

        <el-table-column   label="{:L('INDEX')}"   :formatter="handleIndex" width="65"  ></el-table-column>

        <el-table-column prop="name" header-align="center" label="客户姓名" width="140" ></el-table-column>

        <el-table-column prop="type" header-align="center" sortable="custom" label="客户类型" width="180" >
          <template scope="scope">
            {{ getType(scope.row.type, 'customerType') }}
          </template>
        </el-table-column>
        <el-table-column  prop="realname" header-align="center" sortable="custom" label="跟踪员工"  width="200"></el-table-column>
        <el-table-column prop="qq" label="QQ号" header-align="center" width="160">
          <template scope="scope">
            {{ scope.row.qq }}
            <a v-if="scope.row.qq" :href="getTenct(scope.row.qq)">
              <img width="20"  src="__PUBLIC__/images/0df431adcbef7609bca7d58a2adda3cc7cd99e73_r2_c2.jpg" alt="">
            </a>
          </template>
        </el-table-column>
        <el-table-column prop="qq_nickname" header-align="center" label="QQ昵称"  width="140"></el-table-column>

        <el-table-column prop="phone" label="手机" align="center" width="140"></el-table-column>

        <el-table-column  prop="last_track" sortable="custom" label="最后跟踪时间" align="center" width="180">
        </el-table-column> 
        <el-table-column  prop="commission" label="跟踪方比例" width="110">
          <template scope="scope">
            {{ scope.row.commission+"%" }}
          </template>
        </el-table-column>
        <el-table-column  prop="add_commission" label="锁定方比例" width="110">
          <template scope="scope">
            {{ scope.row.add_commission+"%" }}
          </template>
        </el-table-column>
        <el-table-column  prop="plan" label="计划跟踪时间" align="center" width="180"></el-table-column>
        <el-table-column  prop="conflict" label="最后冲突时间" align="center" width="180"></el-table-column>
        <el-table-column  label="地区" header-align="center" width="135">
          <template scope="scope">
            {{ scope.row.province_name+"-"+scope.row.city_name }}
          </template>
        </el-table-column>
        <el-table-column prop="sex" header-align="center" label="性别" width="80" >
          <template scope="scope">
            {{ getType(scope.row.sex, 'sexType') }}
          </template>
        </el-table-column>



        <el-table-column inline-template :context="_self"  fixed="right"  align="center" label="操作" width="160">
          <span>
            <el-button @click="handleDelete($index, row)"  size="small" type="danger">放入回收站</el-button>
          </span>
        </el-table-column>
      </el-table>
    </el-col>
  </el-row>

  <!-- toolbar -->
  <el-row type="type"  justify="space-between" align="middle"  class="row-bg">
    <el-col :span="12">
      <div class="grid-content bg-purple">
        <span class="wrapper">
          <el-tooltip content="选择客户录入跟踪信息" placement="right">
            <el-button size="small" @click="openDialog('addTrack')" type="primary">录入跟踪</el-button>
          </el-tooltip>

          <el-tooltip content="选择客户录入投诉意见" placement="right">
            <el-button size="small" @click="openDialog('complain')" type="primary" style="margin-left:10px;">客户投诉</el-button>
          </el-tooltip>

          <el-tooltip content="选择客户对其转让给他人" placement="right">
            <el-button size="small" @click="openDialog('addTransfer')"  type="warning" style="margin-left:10px;">转让</el-button>
          </el-tooltip>
        </span>
      </div>
    </el-col>
    <el-col :span="12">
      <div class="grid-content bg-purple-light pull-right">

        <!-- page -->
        <include file="Common:_pagination" />
        <!-- / page -->
        
      </div>
    </el-col>

  </el-row>
  </div>

  <div id="app2" class="b" style="margin:5px -10px 5px;">
    <!--<div class="superaddition">

    </div>-->
    <!--style="position: relative;top:-40px;"-->
    <el-row >
     <el-col :span="24">
        <el-tabs type="border-card">
          <el-tab-pane label="跟踪记录">
            <el-table :data="tableData"  empty-text="请点击客户显示跟踪信息" border style="width: 100%" 
            @row-dblclick="viewtraceContents">
              <el-table-column prop="user"  label="操作员工" header-align="center">
              </el-table-column>
              <el-table-column prop="type"  label="客户类型(当前)" header-align="center">
             
              </el-table-column>
              <el-table-column prop="name"  label="客户姓名" header-align="center">
              </el-table-column>
              <el-table-column label="跟踪内容"  header-align="center">
                <template scope="scope">
                  {{scope.row.content | handleString}}
                </template>
              </el-table-column>
              <el-table-column prop="created_at" label="跟踪时间" align="center">
              </el-table-column>
              <el-table-column prop="track_text" header-align="center" label="跟踪类型" >
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="投诉记录">
            <el-table :data="tableDataOne"  empty-text="请点击客户显示跟踪信息" border style="width: 100%"  @row-dblclick="viewComplainContents">
              <el-table-column prop="user" label="操作员工" header-align="center">
              </el-table-column>

              <el-table-column prop="type" label="客户类型(当前)" align="center">
              </el-table-column>

              <el-table-column prop="name" label="客户姓名" align="center" >
              </el-table-column>
              
              <el-table-column label="投诉内容" header-align="center">
                <template scope="scope">
                  {{scope.row.content | handleString}}
                </template>
              </el-table-column>

              <el-table-column prop="created_at" label="投诉时间" width="180" align="center">
              </el-table-column>

              <el-table-column prop="track_text" label="投诉类型" align="center">
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
     </el-col>
    </el-row>
  </div>
</div>

<div class="dialogWrapper" v-show="show" style="display: none">

 
  <!-- 编辑 -->
  <include file="_edit" />
  <!-- 显示客户一般资料 -->
  <include file="_userInfo"/>
  <!-- 录入跟踪  -->
  <include file="_track" />
  <!-- / 录入跟踪 -->

  <!-- 录入转让 -->
  <include file="_transfer"/>
  <!-- /录入转让 -->

  <!-- V类客户资料 -->
  <include file="_realInfo" />
  <!-- /V类客户资料 -->

  <!-- 客户全部资料 -->
  <include file="_detail"/>
  <!-- /客户全部资料 -->

  <include file="Customer::_preCheck" />
  <include file="_quitOut" />
  <!-- 跟踪内容 -->
  <include file="Customer::_traceContent" />
  <!-- /跟踪内容 -->
  <!-- 投诉内容 -->
  <include file="Customer::_complainContent" />
  <!-- /投诉内容 -->
  <!-- 录入投诉 -->
  <include file="_complain" />
  <!-- 录入投诉 -->
</div>

</div>

</block>
<block name="scripts">
<script src="__PUBLIC__/js/contactValidate.js"></script>
<script>

//表单验证
var checkPhone=function(rule,value,callback){
   var phoneReg = /^1[34578]\d{9}$/;
   if(value==='' || value===null){
     callback();
   }else if(!phoneReg.test(value)){
     callback('手机号格式错误');
   }else{
     callback();
   }
}
var checkQQ=function(rule,value,callback){
  var number=/^\d+$/;
  if(value==='' || value===null){
    callback();
  }else if(!number.test(value)){
    callback('QQ号格式错误');
  }else{
    callback();
  }
}
var checkIdNum=function(rule,value,callback){
  var number=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  if(!number.test(value)){
    callback('身份证号格式错误');
  }else{
    callback();
  }
}

Vue.filter("handleString", function(v) {
  if(v!=''){
    var cnt=v.substring(0,3)+'......';   
  }
    return cnt;
});

</script>
<script>
  page.addRealInfoUrl = "{:U('realInfo')}";
  page.addTrackFormUrl = "{:U('addTrackLogs')}";
  page.addPlanFormUrl = "{:U('addPlanLogs')}";
  page.addRemindFormUrl = "{:U('setRemid')}";
  page.addChoiceFormUrl = "{:U('setImportant')}";
  page.getGroupMemberListUrl = "{:U('getGroupMemberList')}";
  page.getTrackLogUrl = "{:U('trackInfo')}";
  page.addTransferFormUrl = "{:U('trasnfCustomers')}";
  page.getGroupsUrl= "{:U('getDepartGroups')}";
  page.addComplainFormUrl = "{:U('CommonHandleLogic/addComplain')}";
  window.defaultOption.setDatas({
    flag:false,
    advanchShow:false,
    buttonText:"展开",
    ddprops:'name',
    dialogVisible:false,
    sb:[],
    tableData: [{'name':'',
                 'created_at':'',
                 'type':'',
                 'track_type':'',
                 'content':'',
                 'user':''
    }],
    tableDataOne: [{'name':'',
                 'created_at':'',
                 'type':'',
                 'track_type':'',
                 'content':'',
                 'user':''     
    }],
    customerType:{:json_encode($customerType)},
    sexType:{:json_encode($sexType)},
    Quality:{:json_encode($Quality)},
    Year:{:json_encode($Year)},
    Income:{:json_encode($Income)},
    Sty:{:json_encode($Sty)},
    Money:{:json_encode($Money)},
    Energy:{:json_encode($Energy)},
    Problem:{:json_encode($Problem)},
    Mode:{:json_encode($Mode)},
    Attitude:{:json_encode($Attitude)},
    Profession:{:json_encode($Profession)},
    Intention:{:json_encode($Intention)},
    Source:{:json_encode($Source)},
    Proportion:{:json_encode($Proportion)},
    Remind:{:json_encode($Remind)},
    GoodsType:{:json_encode($GoodsType)},
    ServiceCycle:{:json_encode($ServiceCycle)},

    products:{:json_encode($Products)},

    provinces:[],
    cities:[],
    deps:[],//
    reUsers:[],//
    multipleSelection: [],
    alertDesc:"",
    logType:{:json_encode($logType)},
    steps:{:json_encode($steps)},
    searchGroup:{:json_encode($searchGroup)},
    memeberList:[],
    Departments:{:json_encode($Departments)},
    reGroup:[],
   
    editRules:{
      name:[
        { required: true, message: '请输入客户姓名', trigger: 'blur' },
      ],
      phone:[
        { required: true, message: '请输入客户手机', trigger: 'blur' },
        { validator: checkPhone , trigger: 'blur' },
      ],
      phone2:[
        { validator: checkPhone, trigger: 'blur' }
      ],
      qq:[
        { pattern:/^\d+$/, message: 'QQ号必须为数字'},
        { validator: checkQQ, trigger:'blur' },
      ],
      qq2:[
        { pattern:/^\d+$/, message: 'QQ号必须为数字'},
        { validator: checkQQ, trigger:'blur' },
      ],
      weixin:[
          { min: 6, max: 20, trigger:'blur', message:"长度为6-20个字符" },
          { pattern:/^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/, message:"仅支持数字、下划线或减号，以字母开头", trigger:'blur'},

          // { validator: WxValidata, trigger:'blur' },
      ],
      weixin2:[
          {min: 6, max: 20, trigger:'blur', message:"长度为6-20个字符" },
          { pattern:/^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/, message:"仅支持数字、下划线或减号，以字母开头", trigger:'blur'},
      ],
      type:[
        { required:true, message:'请选择客户类型',trigger:'blur'},
      ],
      money:[
        { required:true, message:'请选择客户资料量',trigger:'blur'},
      ],
      source:[
        { required:true, message:'请选择客户来源', trigger:'blur'},
      ]
    },

    qq_disabled:false,
    weixin_disabled:false,
    phone2_disabled:false,
    qq2_disabled:false,
    weixin2_disabled:false,

    realInfoRules:{
      identity:[
         { required: true, message: '请输入身份证号', trigger: 'blur' },
         { validator: checkIdNum, trigger:'blur' },
      ],
      type:[{ required: true, message: '请选择产品类型', trigger: 'blur' },],
      expense:[
        { required: true, message: '请输入产品金额', trigger: 'blur',type: 'number' },
        
      ],
      cycle:[{ required: true, message: '请选择服务周期', trigger: 'blur' },],
      address:[{ required: true, message: '请输入通讯地址', trigger: 'blur' },],
    },
    transferRules:{
      rec_user:[
        { required:true, message:"请选择接受员工", trigger:'blur'}
      ],
      rec_dep:[
        { required:true, message:"请选择接受部门", trigger:'blur'}
      ],
      rec_group:[
        { required:true, message:"请选择接受小组", trigger:'blur'}
      ],
    },
    cusNameList:[],

  }).setForm('search', {
    field: '',
    start:'',
    end:'',
    type:'',
    group:"",
    ctrl:'advance',
    name:"",
    phone:"",
    qq:"",
    track_start:"",
    track_end:"",
    user_id:"{$user_id}"
  }).setForm('edit',{
    id:"",
    name:"",
    type:"",
    phone:"",
    phone2:"",
    qq:"",
    qq2:"",
    qq_nickname:"",
    qq_nickname2:"",
    sex:0,
    weixin:"",
    weixin_nickname:"",
    area_province:null,
    area_city:null,
    quality:'',
    year:'',
    re_income:'',
    style:'',
    money:'',
    energy:'',
    problem:'',
    mode:'',
    attitude:'',
    profession:'',
    intention:'',
    source:'',
    remark:"",
  }).setForm('preCheck',{

  },true).setForm('addTrack',{
    cus_id:"",
    next_datetime:'',
    track_type:'',
    to_type:"",
    content:'',
    name:"",
    step:"",
    track_type:'',
  },true).setForm('addTransfer',{
     name:'',
     cus_id:[],
     rec_dep:'',
     rec_group:'',
     rec_user:'',
     proportion:'2',
     content:'',
  },true).setForm('realInfo',{
    identity:'',
    pdt_id:'',
    expense:'',
    cycle:'',
    address:'',
    cus_id:'',
    fm:'',
  },true).setForm('traceContent',{
    content:'',
  },true).setForm('complainContent',{
    content:'',
  },true).setForm('quitOut',{

  },true).setForm('complain',{
    cus_id:'',
    type:'',
    name:'',
    content:'',
  }, true).setMethod('getType', function(type, field){
      return this[field][type];
  }).setMethod('beforeList', function(data){
        data.forEach(function(currentValue){
          //将string类型转换为number和为0的变为空
          currentValue.quality = currentValue.quality == 0?"":currentValue.quality;      
          currentValue.year = currentValue.year == 0?"":currentValue.year;      
          currentValue.re_income = currentValue.re_income == 0?"":currentValue.re_income;      
          currentValue.style = currentValue.style == 0?"":currentValue.style;      
          currentValue.money = currentValue.money == 0?"":currentValue.money;      
          currentValue.energy = currentValue.energy == 0?"":currentValue.energy;      
          currentValue.problem = currentValue.problem == 0?"":currentValue.problem;      
          currentValue.mode = currentValue.mode == 0?"":currentValue.mode;      
          currentValue.attitude = currentValue.attitude == 0?"":currentValue.attitude;      
          currentValue.profession = currentValue.profession == 0?"":currentValue.profession;      
          currentValue.intention = currentValue.intention == 0?"":currentValue.intention;      
          currentValue.source = currentValue.source == 0?"":currentValue.source;          
          //console.log(typeof(currentValue.quality));
       })
     return data;
  }).setMethod('provinceChange', function(v){
    var vmThis = this;
    this.$http.get('{:U("Area/getAreasByPid")}', {params:{pid:v} }).then(function(response){
      var cities = [];
       response.body.forEach(function(currentValue,index){
        cities.push({id: currentValue.id, name: currentValue.name});
       })
       vmThis.$set(vmThis, 'cities', cities);
    });
  }).setMethod('depChange',function(v){
     //console.log(v);
     var vmThis=this;
     this.$http.get('{:U("getRecUser")}', {params:{id:v}}).then(function(response){
       var reUsers = [];
       response.body.forEach(function(currentValue,index){
         reUsers.push({value:currentValue.id,name:currentValue.realname});
       })
       vmThis.$set(vmThis,'reUsers',reUsers);
     });
  }).setMethod('beforeEdit',function(){
    if (!this.$refs['editselect']) {
      this.provinceChange(this.editForm.area_province);
    }
  }).setMethod('handleSelectionChange', function(val){
    this.multipleSelection = val;
  }).setMethod('commonSelect',function(x){
    var form = x;
    var vmThis = this;
    if (this.multipleSelection.length ==0 ||  this.multipleSelection.length>1) {
      this.closeDialog(form);
      this.$message.error('请先选择一位客户');
      return false;
    } else {
      var  row = this.multipleSelection.pop();
      this[FormName.getForm(x)].name = row.name;
      this[FormName.getForm(x)].cus_id = row.id;
      this.complainForm.type = row.type;
      this.complainForm.to_id = row.salesman_id;
      this.row=row;
      return row;
    }
  }).setMethod('beforeAddTrack', function(){
    this.commonSelect('addTrack');
  }).setMethod('beforeAddComplain', function(){
    this.commonSelect('complain');
  }).setMethod('beforeAddPlan',function(){
    this.commonSelect('addPlan');
    // this.dialogLabelWidth = "140px";
  }).setMethod('beforeAddTransfer',function(){

    if (this.multipleSelection.length ==0) {
      this.closeDialog('addTransfer');
      this.$message.error('请先至少选择一位客户');
    } else {
      var tmp = [];
      for (var i = this.multipleSelection.length - 1; i >= 0; i--) {
        tmp.push(this.multipleSelection[i].id);
      }
    }

    for (var x = 0,len = this.multipleSelection.length;x < len;x++) {
      this.cusNameList.push(this.multipleSelection[x].name);
    }
    this.addTransferForm.cus_id = tmp;
    console.log(typeof(this.Profession));
    this.addTransferForm.name = this.cusNameList.join(' | ');

  }).setMethod('beforeAddRemind',function(){      
    this.commonSelect('addRemind'); 
  }).setMethod('beforeAddChoice',function(){
    //this.commonSelect('addChoice');
    var re = this.commonSelect('addChoice');
    if(re !== false){
      this.addChoiceForm.type = this.customerType[re.type];
      this.addChoiceForm.choose = parseInt(re.important);
    }   
  }).setMethod('beforeShowDetail',function(){
    if(this.commonSelect('showDetail') !== false){
      this.showDetailForm = this.row; 
    }
  }).setAdvancedSearch().setVueHook('mounted', function(){
    var vmThis = this;
    this.$http.get('{:U("Area/getAreasByPid")}', {params:{pid:1} }).then(function(response){
      var provinces = [];
      response.body.forEach(function(currentValue,index){
        provinces.push({id: currentValue.id, name: currentValue.name});
      })
      vmThis.$set(vmThis, 'provinces', provinces);
    });
    // this.dialogLabelWidth = "100px";
  }).setMethod('trackLog',function(row,event,column){
      this.$http.post(page.getTrackLogUrl,row).then(function(response){
        this.tableData = response.body;
      },function(response){
        console.log("操作失败");
      });

      this.$http.post("{:U('CommonFindDetail/complainInfo')}",row).then(function(response){
        this.tableDataOne = response.body;
      },function(response){
        console.log("操作失败");
      });

  }).setMethod('userInfo',function(row,event){
      var index = this.dataList.indexOf(row);
      this.realInfoForm.cus_id = row.id;
      this.$http.get('{:U("Customer/findRealInfo")}', {params:{cus_id:row.id} }).then(function(response){
         this.realInfoForm.identity = response.body.identity;
         this.realInfoForm.pdt_id = response.body.pdt_id;
         this.realInfoForm.expense = response.body.expense;
         this.realInfoForm.cycle = response.body.cycle;
         this.realInfoForm.address = response.body.address;
         // this.realInfoForm.cus_id = response.body.cus_id;
      });

      this.handleEdit(index, row);
  }).setMethod('setField', function(v,id){
      this.flag=id;
      this[FormName.getFormName('search')].field = v;
      this.loadDatalist();
  }).setMethod('refresh',function(){
    window.location.reload();

  }).setMethod('startDateChange', function(v){
    this.searchForm.start = v;
  }).setMethod('endDateChange', function(v){
    this.searchForm.end = v;
  }).setMethod('startTrackChange', function(v){
    this.searchForm.track_start = v;
  }).setMethod('endTrackChange', function(v){
    this.searchForm.track_end = v;
  }).setMethod('searchCustomer', function(){
    
  }).setMethod('toggleShow', function(){
    this.advanchShow = ! this.advanchShow;
    if (this.buttonText == '展开') {
      this.buttonText = "收起";
    } else {
      this.buttonText = '展开';
    }
  }).setMethod('groupChange', function(v){
    this.searchForm.user_id="";
    this.$http.get(page.getGroupMemberListUrl, {params:{id:v}}).then(function(response){
      this.memeberList = response.body;
    }, function(response){
      this.$message.error('出错了');
    })
  }).setMethod('sortChange', function(sortObject){

    var sortMap = {
      ascending: 'asc',
      descending: 'desc'
    }

    if (sortObject.column === null) {
      delete this.searchForm.sort_field;
      delete this.searchForm.sort_order;
    } else {
      this.searchForm.sort_field = sortObject.prop;
      this.searchForm.sort_order = sortMap[sortObject.order];
    }


    this.dataLoad = true;
    this.loadDatalist();

    
  }).setMethod('addRealInfo',function(url){
      var  vmThis = this;
      this.realInfoFormSubmitStatus = true;
      this.$http.post(url,this.realInfoForm).then(function (response) {
        vmThis.$message({
              message: '操作成功',
              type: 'success'
            });
        setTimeout(function(){
          vmThis.realInfoFormDialog = false;
          vmThis.realInfoFormSubmitStatus = false;
          vmThis.$refs.realInfoForm.resetFields(); 
          if(vmThis.realInfoForm.fm=='edit'){
             vmThis.editFormSubmit(page.editFormUrl, 'edit');
          }else if(vmThis.realInfoForm.fm=='add'){
             vmThis.addFormSubmit(page.addFormUrl, 'add'); 
          }else{
             vmThis.addTrackFormSubmit(page.addTrackFormUrl, 'addTrack'); 
          } 
        }, 2000);  
      }, function(response){  
          vmThis.$message({
            message: '操作失败：'+response.body.info,
            type: 'error'
          });
          setTimeout(function(){
            vmThis.realInfoFormSubmitStatus = false;
          },2000);
      });
  }).setMethod('addTrackSubmit',function(url,form){
    FormName.type = form;
    var  formName    =  FormName.getFormName(); 
    // if(this[formName].to_type=='V'){
    //    this.realInfoFormDialog=true;
    //    this.realInfoForm.fm = 'addTrack'; 
    // }else{ 
    //    this.addTrackFormSubmit(url, form);
    // } 
    this.addTrackFormSubmit(url, form);
  }).setMethod('editSubmit',function(url, form){
    FormName.type = form;
    var  formName    =  FormName.getFormName();  //form+"Form"; 
    // if(this[formName].type=='V'){
    //    this.realInfoFormDialog=true;
    //    this.realInfoForm.fm = 'edit'; 
    // }else{ 
    //    this.editFormSubmit(url, form);
    // }   
    this.editFormSubmit(url, form);
  }).setMethod('viewtraceContents',function(row,event){
    // var index = this.tableData.indexOf(row);
    this.traceContentFormDialog = true;
    this.traceContentForm.content = row.content;
  }).setMethod('viewComplainContents',function(row,event){
    this.complainContentFormDialog = true;
    this.complainContentForm.content = row.content;
  }).setMethod('searchFunction', function(){
    this.searchForm.field = "";
    this.dataLoad = true;
    this.loadDatalist();
  }).setMethod('departChange', function(v){
    this.$http.get(page.getGroupsUrl,{params:{id:v}}).then(function(response){
      this.addTransferForm.rec_group = "";
      this.reGroup = response.body;
    },function(response){

    })
  }).setMethod('pdtChange',function(v){
   // alert(v);
    var vmThis = this;
    this.$http.get('{:U("Products/getProduct")}', {params:{id:v} }).then(function(response){
      console.log(response);
      vmThis.realInfoForm.expense=response.body.price;
      vmThis.realInfoForm.cycle=response.body.service_cycle;
    });
  }).setMethod('handleClose',function(){
    this.cusNameList = [];
  }).setMethod('complainSubmit',function(url){
    var  vmThis   = this;
    this.complainFormSubmitStatus = true;
    this.$http.post(url,this.complainForm).then(function(response){
      vmThis.$message({message: '操作成功',type: 'success'});
      setTimeout(function(){
        vmThis.complainFormDialog = false;
        vmThis.complainFormSubmitStatus = false;
        vmThis.$refs.complainForm.resetFields(); 
        vmThis.refresh();
      }, 2000);  
    },function(response){
      vmThis.$message.error("操作出错啦");
    });
  });
</script>
</block>